﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Linq;
using System.Text;
using Core.Model;

namespace Data
{
    public class Db : DbContext
    {
        public Db()
            : base("DB")
        {
        }

        public DbSet<User> Users { get; set; }
        public DbSet<Role> Roles { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //modelBuilder.Entity<User>().HasMany(r => r.Roles).WithMany(o => o.Users).Map(f =>
            //{
            //    f.MapLeftKey("UserId");
            //    f.MapRightKey("RoleId");
            //});
            //modelBuilder.Entity<User>()
            //            .Property(p => p.DtCreation)
            //            .IsConcurrencyToken()
            //            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);

            base.OnModelCreating(modelBuilder);
        }
    }
    public class DbInitialzer : DropCreateDatabaseIfModelChanges<Db>
    {
        protected override void Seed(Db context)
        {
            base.Seed(context);
        }
    }
}
